package com.mall.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mall.annotation.OperationLog;
import com.mall.db.domain.Members;
import com.mall.db.service.MembersService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/system/mcs")
public class MembersController extends BaseController<Members>{

    @Resource(name = "membersService")
    private MembersService mss;

    @Override
//    @OperationLog(value = "查询会员成员",type = 0)
    public Map<String,Object>find(Members members){
        PageHelper.startPage(members.getPage(),members.getLimit());
        QueryWrapper<Members> qw = new QueryWrapper<>();
        List<Members>list = mss.list(qw);
        PageInfo<Members>page = new PageInfo<>(list,members.getPage());
        return this.findMap(page.getList(),page.getTotal());
    }
    @Override
    @OperationLog(value = "编辑会员成员",type = 0)
    public Map<String,Object>update(Members members){
        boolean b = mss.updateById(members);
        return this.iud("编辑",b,members);
    }

    @Override
    @OperationLog(value = "新增会员成员",type = 0)
    public Map<String, Object> add(Members members) {
        //TODO 密码加密
        boolean b=mss.save(members);

        return this.iud("新增",b,members);
    }

}
